home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / credit1a / ccredits.cls next >
Text File  |  1999-08-28  |  2KB  |  51 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "cCredits"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = False
  10. Const Yspeed = 1 ' Move the credits at the speed of 1 pixel each loop
  11. Const ConstColors = 255 'how many shades of gray do you want to fade in & out
  12. Private C(ConstColors) As Long ' Array of colours (For fading)
  13. Public PosY As Long ' Y starting text position
  14.  
  15. Private Sub Class_Initialize()
  16.   For i = 0 To ConstColors
  17.     ' Greyscale
  18.     C(i) = RGB(i * Int(256 / ConstColors), i * Int(256 / ConstColors), i * Int(256 / ConstColors))
  19.     'green
  20.     'C(i) = RGB(0, i * Int(256 / ConstColors), 0)
  21.   Next i
  22. End Sub
  23.  
  24. Public Sub Draw(hDC As Long, SWidth As Long, SHeight As Long)
  25.   Dim n As Long
  26.   If PosY < -(14 * (UBound(Strings) + 1)) Then PosY = SHeight
  27.   For i = 0 To UBound(Strings)
  28.     If (PosY + (i * 14)) < Int(SHeight / 2) Then
  29.       n = Int(SHeight / 2) - (Int(SHeight / 2) - (PosY + (i * 14)))
  30.       If n >= 0 And n < ConstColors Then
  31.         SetTextColor hDC, C(n)
  32.       Else
  33.         If n < 0 Then
  34.           SetTextColor hDC, C(0)
  35.         Else
  36.           SetTextColor hDC, C(ConstColors)
  37.         End If
  38.       End If
  39.     Else
  40.       n = Int(SHeight - (PosY + (i * 14)))
  41.       If n > 0 And n < ConstColors Then
  42.         SetTextColor hDC, C(n)
  43.       Else
  44.         SetTextColor hDC, C(ConstColors)
  45.       End If
  46.     End If
  47.     TextOut hDC, 0, (i * 14) + PosY, Strings(i), Len(Strings(i))
  48.   Next i
  49.   PosY = PosY - Yspeed ' Move the credits at the speed of 'Yspeed' pixels each loop
  50. End Sub
  51.